package ModelLayer;
import java.util.ArrayList;

/**
 * Write a description of class Person here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Person
{
    private String id;
    private String name;
    private String address;
    private String postalCode;
    private String city;
    private String phone;// instance variables - replace the example below with your own
    private ArrayList<Loan> loans;

    /**
     * Constructor for objects of class Person
     */
    public Person(String id, String name, String address, String postalCode, String city, String phone)//constructor
    {
      this.id = id;
      this.name = name;
      this.address = address;
      this.postalCode = postalCode;
      this.city = city;
      this.phone = phone;
        loans=new ArrayList<Loan>();
     }
     
     /**
      * Sets the id field.
      */
     public void setID(String id)
     {
         this.id = id;
     }
     
     /**
      * Sets the name field.
      */
     public void setName(String name)
     {
         this.name = name;
     }
     
     /**
      * Sets the address field.
      */
     public void setAddress(String address)
     {
         this.address = address;
     }
     
     /**
      * Sets the postal code field.
      */
     public void setPostalCode(String postalCode)
     {
         this.postalCode = postalCode;
     }
     
     /**
      * Sets the city field.
      */
     public void setCity(String city)
     {
         this.city = city;
     }
     
     /**
      * Sets the phone field.
      */
     public void setPhone(String phone)
     {
         this.phone = phone;
     }
     
     /**
      * Returns the id field.
      */
     public String getID()
     {
         return id;
     }
     
     /**
      * Returns the name field.
      */
     public String getName()
     {
         return name;
     }
     
     /**
      * Returns the address field.
      */
     public String getAddress()
     {
         return address;
     }
     
     /**
      * Returns the postal code field.
      */
     public String getPostalCode()
     {
         return postalCode;
     }
     
     /**
      * Returns the city field.
      */
     public String getCity()
     {
         return city;
     }
     
     /**
      * Returns the phone field.
      */
     public String getPhone()
     {
         return phone;
     }
     
     
     public String toString() //returns string with data about a person
     {
         String s="ID="+getID()+'\n'+"Name="+getName()+'\n'+"Address="+getAddress()+'\n'+"PostalCode="+getPostalCode()+'\n';
         s+="City="+getCity()+'\n'+"Phone="+getPhone()+'\n';
         
         if(loans.size()==0)
         {
             s+="This person has no loans";
            }
         for (Loan loan1: loans)
         {
             s+="Loan ID="+ loan1.getId()+'\n' + "Period=" + loan1.getPeriod() +'\n';
            }
         return s;
         
        }
     
     public void  addLoan(Loan loan)
     {
         loans.add(loan);
        }
        
     public ArrayList<Loan> getLoanList()
     {
         return loans;
        }
        
     public void deleteLoan(Loan loan)
     {
         loans.remove(loan);
        }
    

    
}
